package com.tmp.alarm;

import com.jd.alarm.model.JobAlarmModel;
import com.tmp.alarm.utils.MySQLUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.ResultSet;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 */
public class Test {

    private  final  static Logger LOGGER = LoggerFactory.getLogger(Test.class);

    public static void main(String[] args) {


       String log = "【aaaaa】;【nnnnn】;【aaaaa】;";
      log = log.substring(0,log.lastIndexOf(";"));
        System.out.println(log);
       /* String rate = "0.9";
        DecimalFormat  df  =new DecimalFormat("#.00");
        String res = df.format(Double.parseDouble(rate));
        System.out.println(res);*/


        /*String content="ide_job的任务数过多,共有:76 个,总任务数有:202 个,所占比例为:37.623764%";
        String title = "ide_job过高";
        String list = "13406426673;13260332129;15656068399";

        SendMessagesUtils.sendMessagesToPhone(list,title,content);*/

        /*Runnable runnable = new Runnable() {
            public void run() {
                // task to run goes here
                LOGGER.info("#######################");
//                testMysql();
                try {
//                    countSubJobWaysRate();
                    CountJobAlarm.countSubJobWaysRateAlarm();
//                    ProgressAlarm.dealProgressAlarm();
                   *//* LOGGER.info("代码段1......");
                    Thread.sleep(200);
                    LOGGER.info("代码段2......");
                    Thread.sleep(200);
                    LOGGER.info("代码段3......");
                    Thread.sleep(200);
                    LOGGER.info("代码段4......");
                    Thread.sleep(200);
                    LOGGER.info("代码段5......");*//*
                } catch (Exception e) {
                    e.printStackTrace();
                }
                LOGGER.info("***********************\n\n\n");
            }
        };
        ScheduledExecutorService service = Executors
                .newSingleThreadScheduledExecutor();
        // 第二个参数为首次执行的延时时间，第三个参数为定时执行的间隔时间,第四个参数是单位(有秒s分min毫秒microSeconds等)
        service.scheduleAtFixedRate(runnable, 3, 60, TimeUnit.SECONDS);*/
    }


    public static final void testMysql() {

        String sql = "SELECT * FROM yarn_jobs";
        System.out.println(sql);
        try {
            Connection con = MySQLUtils.getConnection();
            ResultSet rs = MySQLUtils.query(con, sql);
            String ApplicationId = "";
            String ApplicationName = "";
            String ApplicationType = "";
            while (rs.next()) {
                ApplicationId = rs.getString("ApplicationId");
                ApplicationName = rs.getString("ApplicationName");
                ApplicationType = rs.getString("ApplicationType");
            }
            System.out.println("ApplicationId:" + ApplicationId + "  ApplicationName:" + ApplicationName + "  ApplicationType:" + ApplicationType);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}









